import os
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
#编辑路径打开页面
driver = webdriver.Chrome()
file = "file:///"+os.path.abspath("../html/popup.html")
driver.get(file)
# 获取元素
btn = driver.find_elements(By.TAG_NAME, "button")
# accept方法
# btn[0].click()  # 点击alert按钮
# alert = driver.switch_to.alert  # 切换弹窗
# time.sleep(2)
# alert.accept()                  # accept确认
# dismiss方法
# btn[1].click()  # 点击confirm按钮
# confirm = driver.switch_to.alert
# time.sleep(2)
# confirm.dismiss()
# send_keys方法
btn[2].click()  # 点击confirm按钮
prompt = driver.switch_to.alert
time.sleep(2)
prompt.send_keys("今天不是好日子")



driver.quit()

